const triangleNumber = (nums) => {
  if (nums.length < 3) return 0;
  nums.sort((a, b) => a - b);
  let count = 0;
  for (let k = nums.length; k >= 2; k--) {
    let i = 0,
      j = k - 1;
    console.log(k);
    while (i < j) {
      if (nums[i] + nums[j] > nums[k]) {
        count += j - i;
        j--;
      } else {
        i++;
      }
    }
  }
  return count;
};

triangleNumber([0, 1, 1, 1]);
